<?php
/**
 * SqlMap客户端
 *
 * @version $Id: ISqlMapClient.php 312 2008-04-23 16:29:38Z iwind $
 * @package util.sqlmap2
 */
class ISqlMapClient extends IObject {
	private static $sqlMapFactory = array();
	
	/**
	 * 根据文件$configXmlFile取得SqlMap对象
	 * 
	 * 如果在同一个上下文中多次调用，则会自动检查相同文件对应的对象有无存在，
	 * 如果存在，则不再新建对象.
	 *
	 * @param string $configXmlFile 配置文件路径
	 * @return ISqlMap
	 * @throws ISqlMapException
	 */
	public static function getSqlMap($configXmlFile) {
		if (isset(self::$sqlMapFactory[$configXmlFile])) {
			$sqlMap = self::$sqlMapFactory[$configXmlFile];
			try {
				$sqlMap->execute("SELECT 1");//active
			} catch (ISqlMapException $e) {
				ILogger::warning($e->getMessage());
				$sqlMap = new ISqlMap($configXmlFile);
				self::$sqlMapFactory[$configXmlFile] = $sqlMap;
				return $sqlMap;
			}
			return $sqlMap;
		}
		$sqlMap = new ISqlMap($configXmlFile);
		self::$sqlMapFactory[$configXmlFile] = $sqlMap;
		return $sqlMap;
	}
}

?>